﻿<%@page import="com.hh.bss.util.StringHelper" %>
<%
  String jobId=request.getParameter("jobId");  
  if (StringHelper.isEmpty(jobId)) jobId="0";
  String type=request.getParameter("type");   
  
%> 
<!DOCTYPE html>  
<html>  
<head>  
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
    <meta name="keywords" content="职位">  
    <meta name="description" content="职位">  
    <title>职位</title>  
    
    <%@ include file="/WEB-INF/inc/default.jsp"%>
    <jsp:include page="/WEB-INF/inc/dic.jsp"/>    

</head>  
<script type="text/javascript">  

   var jobId=<%=jobId%>;
            
</script>
<body>  
    
      
   
    <!-- edit form窗体（开始） -->  
    <div class="easyui-panel"  style="width:1200px;height:530px">  
        <form id="fm" method="post" enctype="multipart/form-data" novalidate>  
        	  	  	 <input type="hidden" name="id" > 
        	  	  	 <input type="hidden" name="custId" >
        	  	  	 <input type="hidden" name="contractId" >
        	  	  	 
        <table cellSpacing=0 cellPadding=0 class="dv-table" style="width:100%;border:1px solid #ccc;padding:5px;margin-top:0px;">        	  	  	 
        	 <tr>
        	 	  <td>职位合作性质</td>
        	 	  <td><input class="easyui-combobox" name="jobNature" style="width:200px;"  data-options="data:__getConstantCategory('JOB_NATURE'),valueField:'code', textField:'value', multiple:false,panelHeight:'auto',mode:'remote' "></td>
        	 	  <td>客户<font color="red">*</font></td>
        	 	  <td><input name="custName" class="easyui-box easyui-validatebox"  required="true"><a href="#" class="easyui-linkbutton" onclick="javascript:selectCustomerBd()">选择</a></td>
        	 </tr>        	 
        	 <tr>
        	 	  <td>职位名称<font color="red">*</font></td>
        	 	  <td><input name="name" class="easyui-box easyui-validatebox"  required="true"></td>
        	 	  <td>职位合同</td>
        	 	  <td><input name="contractName" class="easyui-box"><a href="#" class="easyui-linkbutton" onclick="javascript:selectContract()">选择</a></td>        	 	  
        	 </tr>	
        	 <tr>
        	 	  <td>职位状态</td>
        	 	  <td><input class="easyui-combobox" name="status" style="width:200px;"  data-options="data:__getConstantCategory('JobStatus'),valueField:'code', textField:'value', multiple:false,panelHeight:'auto',mode:'remote' "></td>
        	 	  <td>客户职位联系人</td>
        	 	  <td><input class="easyui-combobox" name="hrContacter" style="width:200px;"  data-options="data:'/customer/customerContacter/extcustomercontactlist.do?role=JC',valueField:'cvId', textField:'cvName', multiple:false,panelHeight:'auto',mode:'remote' "></td>        	 	  
        	 </tr>
        	 <tr>
        	 	  <td>职位编号</td>
        	 	  <td></td>
        	 	  <td>客户收款联系人</td>
        	 	  <td><input class="easyui-combobox" name="arContacter" style="width:200px;"  data-options="data:'/customer/customerContacter/extcustomercontactlist.do?role=FC',valueField:'cvId', textField:'cvName', multiple:false,panelHeight:'auto',mode:'remote' "></td>        	 	  
        	 </tr>
        	 <tr>
        	 	  <td>一级行业<font color="red">*</font></td>
        	 	  <td>
        	 	  <input class="easyui-combobox" name="industry_parent" style="width:200px;"  data-options="data:__getCategoryByParant('INDUSTRY', 0),valueField:'id', textField:'codeNameCn', multiple:false,panelHeight:'auto',mode:'remote'
		             	,onSelect: function(rec){  
                         
                         $('#second_industry').combobox('loadData', __getCategoryByParant('INDUSTRY', rec.id));  
                         $('#second_industry').combobox('setValue',null);
                     }
		             	 ">
        	 	  </td>
        	 	  <td>二级行业<font color="red">*</font></td>
        	 	  <td><input class="easyui-combobox" id="second_industry" name="industry" style="width:200px;"  data-options="data:{},valueField:'id', textField:'codeNameCn', multiple:false,panelHeight:'auto',mode:'remote' "></td>        	 	  
        	 </tr>
        	 <tr>
        	 	  <td>一级职能<font color="red">*</font></td>
        	 	  <td>
        	 	  <input class="easyui-combobox" name="function_parent" style="width:200px;"  data-options="data:__getCategoryByParant('JOB', 0),valueField:'id', textField:'codeNameCn', multiple:false,panelHeight:'auto',mode:'remote' 
		           	,onSelect: function(rec){              
                       $('#second_job').combobox('loadData', __getCategoryByParant('JOB', rec.id));  
                       $('#second_job').combobox('setValue',null);
                   }
		           	">
        	 	  </td>
        	 	  <td>二级职能<font color="red">*</font></td>
        	 	  <td><input class="easyui-combobox" id="second_job" name="function" style="width:200px;"  data-options="data:__getCategory('JOB'),valueField:'id', textField:'codeNameCn', multiple:false,panelHeight:'auto',mode:'remote' "></td>        	 	  
        	 </tr>
        	 <tr>
        	 	  <td>职级<font color="red">*</font></td>
        	 	  <td><input class="easyui-combobox easyui-validatebox"   name="level" style="width:200px;"  data-options="data:__getCategory('JOBLEVEL'),valueField:'id', textField:'codeNameCn', multiple:false,panelHeight:'auto',mode:'remote' "></td>
        	 	  <td>直属上司</td>
        	 	  <td><input name="direct" class="easyui-box"></td>        	 	  
        	 </tr>
        	 <tr>
        	 	  <td>预计Offer时间</td>
        	 	  <td><input name="offerDt" class="easyui-datebox"></td>
        	 	  <td>预计服务费</td>
        	 	  <td><input name="servicesCharge" class="easyui-numberbox"></td>        	 	  
        	 </tr>
        	 <tr>
        	 	  <td>职位负责人</td>
        	 	  <td><input class="easyui-combobox" name="jobManager" style="width:200px;"  data-options="url:'/auth/systemUser/userlist.do',valueField:'account', textField:'name', multiple:false,panelHeight:'auto',mode:'remote' "></td>
        	 	  <td>职位合作人</td>
        	 	  <td><input class="easyui-combobox" name="jobCooper" style="width:200px;"  data-options="url:'/auth/systemUser/userlist.do',valueField:'account', textField:'name', multiple:false,panelHeight:'auto',mode:'remote' "></td>        	 	  
        	 </tr>
        	 <tr>
        	 	  <td>招聘人数</td>
        	 	  <td><input name="hireNum" class="easyui-numberbox"></td>
        	 	  <td>支持助理</td>
        	 	  <td><input class="easyui-combobox" name="jobAssist" style="width:200px;"  data-options="url:'/auth/systemUser/userlist.do',valueField:'account', textField:'name', multiple:false,panelHeight:'auto',mode:'remote' "></td>        	 	  
        	 </tr>
        	 <tr>
        	 	  <td>职位开发时间</td>
        	 	  <td><input name="openD" class="easyui-datebox"></td>
        	 	  <td>工作地点</td>
        	 	  <td><input class="easyui-combobox" name="workLocation" style="width:200px;"  data-options="data:__getCategory('LOCATION'),valueField:'id', textField:'codeNameCn', multiple:false,panelHeight:'auto',mode:'remote' "></td>        	 	  
        	 </tr>
        	 <tr>
        	 	  <td>职位介绍文件</td>
        	 	  <td><input id="uploadFile" name="uploadFile" type="file"  style="width: 140px"></td>
        	 	  <td><div id="autogenjd" style="display:none"><a href="#" class="easyui-linkbutton" onclick="javascript:autoGenJD()">自动生成JD</a></div></td>
        	 	  <td><p></p></td>        	 	  
        	 </tr>
        	 <tr>
        	 	  <td>职位开放原因</td>
        	 	  <td colspan=3>
        	 	  <textarea name="openResult" style="width:800px;height:100px" ></textarea>
        	 	  </td>
        	 	       	 	  
        	 </tr>
        	 <tr>
        	 	  <td>职位职责</td>
        	 	  <td colspan=3><textarea name="duty" style="width:800px;height:100px" ></textarea></td>
        	 	       	 	  
        	 </tr>
        	 <tr>
        	 	  <td>要求</td>
        	 	  <td colspan=3><textarea name="requirement" style="width:800px;height:100px" ></textarea></td>
        	 	       	 	  
        	 </tr>
        	 <tr>
        	 	  <td>职位其它要求</td>
        	 	  <td colspan=3><textarea name="otherRequire" style="width:800px;height:100px" ></textarea></td>
        	 	       	 	  
        	 </tr>
        	 <tr>
        	 	  <td>职位关闭原因</td>
        	 	  <td colspan=3><textarea name="closeReason" style="width:800px;height:100px" ></textarea></td>
        	 	       	 	  
        	 </tr>
        	 
        </table>
        	  	  	 
        	  	  	 
	        		       		     
        </form>  
        <div id="dlg-buttons" style="text-align:center;padding:5px">  
          <a href="javascript:void(0)" id="btn-save" class="easyui-linkbutton" iconCls="icon-ok" onclick="save()">保存</a>  
          <a href="javascript:void(0)" id="btn-close" class="easyui-linkbutton" iconCls="icon-cancel" onclick="">关闭</a>  
        </div> 
    </div>  
    <!-- edit form窗体（结束） -->  
    
  
    <script type="text/javascript">  
        
        
        var url='/project/contractJob/save.do';
        <%if ("UPDATE".equals(type)){ %>
            url='/project/contractJob/update.do';      
        <% } %>	
        
        var selectCustomerBdWin; 
        var selectContractWin; 
        function setCustomerBd(customer){
                          $('#fm input[name="custName"]').attr("value",customer.name);
                          $('#fm input[name="custId"]').attr("value",customer.id);
        }
        function selectCustomerBd(){
        	           if (selectCustomerBdWin)
                            selectCustomerBdWin.window('open');
                        else selectCustomerBdWin = $.window({
		                 	   	title:"选择客户",
		                 	   	url:"/customer/customerBd/selectBdCustomerPage.do",
		                 	   	isIframe:true,
		                 	   	height:450,
		                 	   	width:1150,
		                 	   	modal:true,		      	   	
		                 	   	width:1100,
		                 	   	onComplete:function(jq,iframe){	
		                 	   		         	   		   	      	   		
		                 	   		   var fwindow = $.window.util.getFrameWindow(iframe);		      	   		
		                 	   		   var ijq = fwindow.jQuery;		
		                 	   		   var curWin=this;   
		                 	   		   
		                 	   		   var curWin=this;
					           
					                      fwindow.closeWin=function(){
					                      	   curWin.window('close');
					                      	  
				                        };
				                        
				                        fwindow.callback=curWin.openerWin.setCustomerBd;
				                        //fwindow.pcallback=curWin.openerWin.addCompanyDB;
		                 	   		   //alert(fwindow.pcallback2);
		                 	   	}
		                 	});
		                 	selectCustomerBdWin.openerWin=window;  
         }
          function setContract(contract){
                          $('#fm input[name="contractName"]').attr("value",contract.name);
                          $('#fm input[name="contractId"]').attr("value",contract.id);
        }
        function selectContract(){
        	           if (selectContractWin)
                            selectContractWin.window('open');
                        else selectContractWin = $.window({
		                 	   	title:"选择合同",
		                 	   	url:"/customer/customerContract/selectContractPage.do",
		                 	   	isIframe:true,
		                 	   	height:400,
		                 	   	modal:true,		      	   	
		                 	   	width:1100,
		                 	   	onComplete:function(jq,iframe){	
		                 	   		         	   		   	      	   		
		                 	   		   var fwindow = $.window.util.getFrameWindow(iframe);		      	   		
		                 	   		   var ijq = fwindow.jQuery;		
		                 	   		   var curWin=this;   
		                 	   		   
		                 	   		   var curWin=this;
					           
					                      fwindow.closeWin=function(){
					                      	   curWin.window('close');
					                      	  
				                        };
				                        
				                        fwindow.callback=curWin.openerWin.setContract;
				                        //fwindow.pcallback=curWin.openerWin.addCompanyDB;
		                 	   		   //alert(fwindow.pcallback2);
		                 	   	}
		                 	});
		                 	selectContractWin.openerWin=window;  
         }
        
        function add(){         	 
            $('#dlg').dialog('open').dialog('setTitle','新增职位');  
            $('#fm').form('clear');  
            url = '/project/contractJob/save.do';  
        }  
        function edit(){  
            //var row = $('#dg').datagrid('getSelected');  
            var rows = $('#dg').datagrid('getSelections');
            if (!rows||rows.length==0){
            	 $.messager.alert('提示','请选择要修改的行','info');
            	 return;
            }
            if (!rows||rows.length>1){
            	 $.messager.alert('提示','不能选择多行','info');
            	 return;
            }
            if (rows){  
                $('#dlg').dialog('open').dialog('setTitle','修改职位');  
                //$('#fm').form('load',rows[0]);  
                $('#fm').form('load','/project/contractJob/get.do?id='+rows[0].id);  
                url = '/project/contractJob/update.do';
            }  
        }  
        function save(){          	   
        
        	  //if (!$('#fm').form('validate')) return; 
        
            $('#fm').form('submit',{  
                url: url,  
                onSubmit: function(){  
                    return $(this).form('validate');  
                },  
                success: function(result){  
                    var result = eval('('+result+')');  
                    console.log(result);
                    if (result.success == true){  
                        //$.messager.alert('信息',result.msg,'info');  
                        //$('#dlg').dialog('close');      // close the dialog  
                        //$('#dg').datagrid('reload');    // reload the user data  
                         alert(result.msg);
                        if (refresh) refresh();
                        if (closeWin) closeWin();
                    } else {  
                       alert(result.msg);
                        //$.messager.alert('错误',result.msg,'error');
                    }  
                }  
            });  
        }  
       function autoGenJD(){
         //自动生成jd文件
         $.post('/project/contractJob/autogen.do?type=2&id='+jobId,{ids:getRecordArray(rows,'id').join(',')},function(result){  
                            if (result.success){  
                                $('#dg').datagrid('reload');    // reload the user data  
                            } else {  
                                 
                                $.messager.alert('错误',result.errorMsg,'error'); 
                            }  
                        },'json');
       }
       $('#fm').form({
        	    onLoadSuccess: function(data){
        	     
        	    	//处理一二级行业
        	    	
        	    	var industry=data.industry?data.industry.toString():null;
        	    	var functionStr=data.function?data.function.toString():null;        	    	
        	    	var industry_parent = __getCategoryCodeParant('INDUSTRY', industry); // 加载职能
        	    	$('#fm input[comboname="industry_parent"]').combobox("setValue",industry_parent);        	    	
        	    	$('#fm input[comboname="industry"]').combobox('loadData',__getCategoryByParant('INDUSTRY', industry_parent));
        	    	
        	    	//处理一二级职能
        	    	var function_parent = __getCategoryCodeParant('JOB', functionStr); // 加载职能        	    	
        	    	$('#fm input[comboname="function_parent"]').combobox("setValue",function_parent);        	    	
        	    	$('#fm input[comboname="function"]').combobox('loadData',__getCategoryByParant('JOB', function_parent));
        	    	
        	    	//设置自动生成
        	    	$('#autogenjd').attr("style","");
        	    	
        	    }
        });
       if (jobId>0)
          $('#fm').form('load','/project/contractJob/get.do?id='+jobId);
    </script>  
     
     

     
     
     
</body>  
</html>